<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
            
    <script type="text/javascript">
    <!-- 
    $(document).ready(function() {
    	$("#doSaveBtn").click(function() {
    		var createGroupNo = $('#createGroupNo').val();//券商代號
    		var createGroupName = $('#createGroupName').val();//券商名稱
    		var createGroupUbm = $('#createGroupUbm').val();//統一編號
    		var createGroupAddress = $('#createGroupAddress').val();//地址
    		var createGroupContactName = $("#createGroupContactName").val();//聯絡人
    		var createGroupContactEmail = $('#createGroupContactEmail').val();//E-MAIL
    		var createGroupContactTelno = $('#createGroupContactTelno').val();//電話號碼
    		var createGroupContactCellno = $('#createGroupContactCellno').val();//手機號碼
    		var value1 = createGroupNo.replace(/^\s+|\s+$/g,'');
    		var value2 = createGroupName.replace(/^\s+|\s+$/g,'');
    		var value3 = createGroupUbm.replace(/^\s+|\s+$/g,'');
    		var value4 = createGroupAddress.replace(/^\s+|\s+$/g,'');
    		var value5 = createGroupContactName.replace(/^\s+|\s+$/g,'');
    		var value6 = createGroupContactEmail.replace(/^\s+|\s+$/g,'');
    		var value7 = createGroupContactTelno.replace(/^\s+|\s+$/g,'');
    		var value8 = createGroupContactCellno.replace(/^\s+|\s+$/g,'');
    		var createGroupUbmRegExp = /^[0-9]{8}$/;
    		var emailRegExp = /[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/;
			var ContactTelNoRegExp = /^0[0-9]{1,3}\-\d{5,8}$/;
			var GroupContactCellRegExp = /^09\d{8}$/;
			var GroupNoRegExp = /^[0-9]{3,4}#?$/;
			var flag = true;
    		var errorMessage = '';
    		
    		if (value1.length <= 0){
    			errorMessage = '券商代號不可空白!!';
    		} else {
    			var count = createGroupNo.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(createGroupNo.charCodeAt(i) < 0 || createGroupNo.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength != 4){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '券商代號為4碼!!';
				 }	 
				 else if(!GroupNoRegExp.test(value1)){
				 	if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	errorMessage = errorMessage + '[券商代號]格式錯誤,格式為xxx#或 xxxx,皆為數字!!';
				 }
    		}
    		
    		if (value2.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '券商名稱不可空白!!';
    		} else {
    			var count = createGroupName.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(createGroupName.charCodeAt(i) < 0 || createGroupName.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 50){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '券商代號不可超過50碼!!';
				 }
    		}
    		
    		if (value3.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '統一編號不可空白!!';
    		} else {
    			if(!createGroupUbmRegExp.test(value3)){
    				if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	errorMessage = errorMessage + '統一編號格式為8位數字!!';
    			}
    		}
    		
    		if (value4.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '地址不可空白!!';
    		} else {
    			var count = createGroupAddress.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(createGroupAddress.charCodeAt(i) < 0 || createGroupAddress.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 200){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '地址不可超過200碼!!';
				 }
    		}
    		
    		
    		if (value5.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '聯絡人不可空白!!';
    		} else {
    			var count = createGroupContactName.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(createGroupContactName.charCodeAt(i) < 0 || createGroupContactName.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 50){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '聯絡人不可超過50碼!!';
				 }
    		}
    		
    		if (value6.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + 'E-MAIL不可空白!!';
    		} else {
    			if(!emailRegExp.test(createGroupContactEmail)){
    				 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '[E-MAIL]格式錯誤!!';
    			}else{
    				var count = createGroupContactEmail.length;
					 var strLength = 0;					 
					 for(var i = 0; i < count; i++){
						  if(createGroupContactEmail.charCodeAt(i) < 0 || createGroupContactEmail.charCodeAt(i) > 255){
						   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
						  }else{
						  	 strLength += 1;
						  }
					 }
					 if(strLength > 100){
					 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
	    		    	 errorMessage = errorMessage + 'E-MAIL不可超過100碼!!';
					 }
    			}
    		}
    		
    		if (value7.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '電話號碼不可空白!!';
    		} else {
    			if(!ContactTelNoRegExp.test(value7)){
						if (errorMessage != '') errorMessage = errorMessage + '<br>';
							errorMessage = errorMessage + '[電話號碼]格式錯誤,格式為0x-xxxxxxxx!!';
	 			}			
    		}
    		
    		if (value8.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	errorMessage = errorMessage + '手機號碼不可空白!!';
    		} else {
    		
				if(!GroupContactCellRegExp.test(value8)){
					if (errorMessage != '') errorMessage = errorMessage + '<br>';
							errorMessage = errorMessage + '[手機號碼]格式錯誤,格式為09xxxxxxxx!!';
				}  			
    		}
    		
            if (errorMessage != '')
            {	
            	flag = false;
                showErrorMessageDialog(errorMessage);
            }
           
    		if(flag){
    			return true;
    		}else{
    			return false;
    		}
		});
		
		$("#doCancelBtn").click(function() {
			$("#hidden\\.doCancelBtn").trigger('click');
		});
		
		<c:if test="${not empty actionBean.message}">
   			showMessageDialog('<c:out value="${actionBean.message }" escapeXml="false"/>');
		</c:if>	
    });
    
    //-->
    </script>
</head>
<body>
	<div id="smallQueryForm"></div>
	<stripes:form id="hidden.queryGroupForm" beanclass="com.feib.stms.action.Stms9009ActionBean" method="post">
	<div id="queryForm">
		<table>
			<tr>
				<td colspan="5" class="queryHeader">券商新增</td>
			</tr>
			<tr>
				<th>券商代號<span id="mustKeyInStar">**</span></th>
				<td colspan="4" ><stripes:text id="createGroupNo" name="createGroup.groupNo" size="4" maxlength="4" /></td>
			</tr>
			<tr>
				<th>券商名稱<span id="mustKeyInStar">**</span></th>
				<td colspan="4"><stripes:text id="createGroupName" name="createGroup.groupName" size="40" maxlength="50" /></td>
			</tr>
			<tr>
				<th>統一編號<span id="mustKeyInStar">**</span></th>
				<td colspan="4"><stripes:text id="createGroupUbm" name="createGroup.ubm" size="8" maxlength="8"  /></td>
			</tr>
			<tr>
				<th>地址<span id="mustKeyInStar">**</span></th>
				<td colspan="4"><stripes:text id="createGroupAddress" name="createGroup.groupAddress" size="40" maxlength="200"  /></td>
			</tr>
			<tr>
				<th>聯絡人<span id="mustKeyInStar">**</span></th>
				<td colspan="2"><stripes:text id="createGroupContactName" name="createGroup.contactName" size="20" maxlength="50"  /></td>
				
				<th>E-MAIL<span id="mustKeyInStar">**</span></th>
				<td><stripes:text id="createGroupContactEmail" name="createGroup.contactEmail" size="20" maxlength="100" /></td>
			</tr>
			<tr>
				<th>電話號碼<span id="mustKeyInStar">**</span></th>
				<td colspan="2"><stripes:text id="createGroupContactTelno" name="createGroup.contactTelno" size="20" maxlength="20" /></td>
				
				<th>手機號碼<span id="mustKeyInStar">**</span></th>
				<td><stripes:text id="createGroupContactCellno" name="createGroup.contactCellno" size="10" maxlength="10" /></td>
			</tr>
			<tr>
				<th>備註</th>
				<td colspan="4"><stripes:text id="createGroupNo" name="createGroup.groupNote" size="30" maxlength="40"  /></td>
			</tr>
			<tr>
				<th>建立者</th>
				<td colspan="2"><c:out value="${actionBean.createGroup.createdBy }" /></td>
				
				<th>建立時間</th>
				<td><fmt:formatDate value="${actionBean.createGroup.createdDate}" pattern="yyyy/MM/dd HH:mm:ss" /></td>
			</tr>
			<tr>
				<th>修改者</th>
				<td colspan="2"><c:out value="${actionBean.createGroup.updatedBy }" /></td>
				
				<th>修改時間</th>
				<td><fmt:formatDate value="${actionBean.createGroup.updatedDate}" pattern="yyyy/MM/dd HH:mm:ss" /></td>
			</tr>
			<tr>
				<td colspan="5" class="queryFunction">
					<stripes:hidden name="createGroup.groupPk" />
					<stripes:hidden name="operation" />
					<stripes:submit id="doSaveBtn" name="doSave" value="確認" class="formBtn"/>
					<stripes:submit id="doCancelBtn" name="doCancel" value="取消" class="formBtn"/>
				</td>
			</tr>
		</table>
	</div>
		<!-- 查詢條件 -->
		<stripes:hidden id="hidden.qryGroupNoForm" name="qryGroupNoForm" />
		<stripes:hidden id="hidden.qryGroupNameForm" name="qryGroupNameForm" />
		<!-- 分頁信息 -->
		<stripes:hidden id="hidden.queryResult.pageNumber" name="queryResult.pageNumber" />
		<stripes:hidden id="hidden.queryResult.sortCriterion" name="queryResult.sortCriterion" />
		<stripes:hidden id="hidden.queryResult.sortDirection" name="queryResult.sortDirection" />
	</stripes:form>

<!-- 取消使用 -->	
<div style="display: none;">
<stripes:form id="hidden.queryGroupForm" beanclass="com.feib.stms.action.Stms9009ActionBean" method="post" onsubmit="javascript: waitingDialog({});">
	<!-- 查詢條件 -->
	<stripes:hidden id="hidden.qryGroupNoForm" name="qryGroupNoForm" />
	<stripes:hidden id="hidden.qryGroupNameForm" name="qryGroupNameForm" />
	<!-- 分頁信息 -->
	<stripes:hidden id="hidden.queryResult.pageNumber" name="queryResult.pageNumber" />
	<stripes:hidden id="hidden.queryResult.sortCriterion" name="queryResult.sortCriterion" />
	<stripes:hidden id="hidden.queryResult.sortDirection" name="queryResult.sortDirection" />
	<stripes:submit id="hidden.doCancelBtn" name="doCancel" value="取消" class="formBtn"/>
</stripes:form>
</div>
</body>
</html>
